package com.heima.test;

/**
 * @author mrchen
 * @date 2022/8/10 16:38
 */
public class ThreadLocalDemo {
    public static void main(String[] args) {
        // 线程变量
        ThreadLocal<Integer> intLocal = new ThreadLocal<Integer>(){
            @Override
            protected Integer initialValue() {
                return 0;
            }
        };
        intLocal.set(intLocal.get() + 1);
        new Thread(()->{
            System.out.println( "线程中 得到intlocal的值1:    "  + intLocal.get());
            intLocal.set(intLocal.get() + 1);
        }).start();
        System.out.println(" 线程中  得到intLocal的值2:  " + intLocal.get());
    }
}
